$(document).ready(function(){
	var dlg='<div id="div_dlg_check" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"><div class="modal-dialog modal-sm" role="document"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button><h4 class="modal-title">验证码</h4></div><div class="modal-body"><p><img id="img_check" src=""/></p><p><input id="text_checkcode" class="col-md-4" type="text" value="" placeholder="输入验证码"/><input type="hidden" id="targeturl" value=""/></p></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">关闭</button><button type="button" id="btn_check" class="btn btn-primary">确定</button></div></div></div></div>';
	$('body').append( dlg );
	$('#btn_check').click( function(){
		var checkcode=$( '#text_checkcode' ).val();
		if( checkcode=="" || checkcode.length<4 ){
			alert("验证码不正确!");
			return;
		}
		window.location.href=$("#targeturl").val()+"/"+checkcode;

	});
	$('.ding_once a').click(function(){
		$('#img_check').attr('src','/index.php?/checkCode/');
		$('#targeturl').val($(this).attr('t'))
		$('#text_checkcode').val("");
		$('#div_dlg_check').modal();
	});
	$('#img_check').click(function(){
		$(this).attr('src','/index.php?/checkCode/');
	});
});
